#!/usr/bin/env python3
# -*- coding: utf-8 -*-

class AdviceAgent:
    """建议智能体：负责提供行动建议"""
    def __init__(self):
        self.advice_rules = self._init_advice_rules()
    
    def _init_advice_rules(self):
        """初始化建议规则库"""
        return {
            'general': {
                'yang': "阳性能量旺盛，可积极进取，但需注意分寸。",
                'yin': "阴性能量主导，宜以柔克刚，顺势而为。"
            },
            'changing': {
                'many': "当前变动较大，宜谨慎行事，多观察少行动。",
                'few': "局部变化，可针对性调整策略。"
            }
        }
    
    def generate_advice(self, hex_num, changing_lines):
        """生成综合建议"""
        # 判断阴阳属性
        hex_type = 'yang' if hex_num % 2 == 1 else 'yin'
        
        # 判断变爻数量
        changing_count = sum(changing_lines)
        changing_type = 'many' if changing_count >= 3 else 'few'
        
        # 组合建议
        advice = []
        advice.append(self.advice_rules['general'][hex_type])
        if changing_count > 0:
            advice.append(self.advice_rules['changing'][changing_type])
        
        return "\n".join(advice)